package demo1;

public class Test2 {
    public static void print(IAnimal iAnimal){
        iAnimal.eat();
    }
    public static void main(String[] args) {
       print(new Dog());
       print(new Cat());
    }
}
interface IAnimal{
  
        String room = "101" ;
        void eat();

}
class Dog implements IAnimal{
    String name = "小狗";
    public void eat(){
        System.out.println(this.name + "在"+ room+"吃饭");
    }
}
class Cat implements IAnimal{

    @Override
    public void eat() {
        System.out.println("小猫在" + room + "吃饭");
    }
}